@extends('backend/layouts/default')
{{--Page Title--}}
@section('title')
<?= !empty($data['unit']->id) ? "Sửa giáo trình" : "Tạo giáo trình"; ?>
@endsection
@section('content')
<h3>
    <span
        class="glyphicon glyphicon-user"></span> <?= !empty($data['unit']->id) ? "Sửa giáo trình" : "Tạo giáo trình"; ?>
</h3>
<form class="form-horizontal" action="<?= route('create/unit') ?>" method="post" accept-charset="utf-8">
    <?= Form::token(); ?>
    <input type="hidden" value="<?= $data['unit']->id ?>" name="data[Unit][id]"/>

    <div class="row">
        <div class="col-md-9">
            <!-- Name -->
            <div class="form-group {{ $errors->has('title') ? 'error' : '' }}">
                <label class="control-label col-md-4" for="name">Tên nhóm</label>

                <div class="col-md-8">
                    <input class="form-control" type="text" name="data[Unit][title]" id="name"
                           value="{{ $data['unit']->title }}"/>
                    {{ $errors->first('title', '<span class="help-inline">:message</span>') }}
                </div>
            </div>
            <div class="form-group {{ $errors->has('slug') ? 'error' : '' }}">
                <label class="control-label col-md-4" for="name">Url</label>

                <div class="col-md-8">
                    <input class="form-control" type="text" name="data[Unit][slug]" id="name"
                           value="{{ $data['unit']->slug }}"/>
                    {{ $errors->first('slug', '<span class="help-inline">:message</span>') }}
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-4" form="parent_id">Giáo trình chính</label>

                <div class="col-md-8">
                    <?= Form::select('data[Unit][parent_id]', $data['units'], Input::old('data[Unit][parent_id]', $data['unit']->parent_id), array('class' => 'form-control')) ?>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-4" for="description">Mô tả</label>

                <div class="col-md-8">
                    <textarea class="form-control" name="data[Unit][description]" id="textareabox">
                        {{ $data['unit']->description }}
                    </textarea>
                </div>
            </div>
            <div class="control-group" align="right">
                <div class="controls">
                    <a class="btn btn-link" href="{{ route('units') }}">Hủy</a>
                    <button type="submit" class="btn btn-success">Lưu</button>
                </div>
            </div>
        </div>
    </div>
</form>
@stop